//业务逻辑数据开始
function A33541_debug_biz_start(inputparam) {
	layer.close(ly_index);
	A33541_Clear_Inpurt();
    /*biz begin*/
	$("#A33541_param_name").val("APP_USER_ZXY");
	if (A013B7_select_t_sub_user_rowId != ""){
		var A013B7_rowCheckData = $("#A013B7_t_sub_user_Events").bootstrapTable('getData')[A013B7_select_t_sub_user_rowId];
		$("#A33541_sub_usercode").val(A013B7_rowCheckData.SUB_USERCODE);
		$("#A33541_sub_code").val(A33541_get_format_SUB_ID(A013B7_rowCheckData.SUB_ID));
	}
	
	if (AD67FA_select_t_page_info_rowId != ""){
		var AD67FA_rowCheckData = $("#AD67FA_t_page_info_Events").bootstrapTable('getData')[AD67FA_select_t_page_info_rowId];
		$("#A33541_param_value1").val(AD67FA_rowCheckData.PAGE_CODE);
	}
	
	var AD67FA_t_page_item = $("#A1A6C5_t_page_item_Events").bootstrapTable('getData');
	var flagIndex = ",";
	$("#A33541_param_values").html("");
	$.each(AD67FA_t_page_item, function (i, obj) {
		var temURL_IN_PARAM = s_decode(obj["URL_IN_PARAM"]);
		if(temURL_IN_PARAM != ""){
			var temParamAry = temURL_IN_PARAM.split(",");
			for(n = 0; n < temParamAry.length; n++){
				if(flagIndex.indexOf(","+temParamAry[n]+",") == -1){
					var parIndex = temParamAry[n].replace("param_value","");
					var input_prarm_value = "<div class=\"form-group\">"
					   	 + "<label class='col-sm-3 control-label'>输入参数" + parIndex + "(param_value" + parIndex+ "=)</label>"
					        + "<div class='col-sm-8'>"
					        + "<input id='A1A6C5_param_value" + parIndex + "' placeholder='请输入参数" +  parIndex + "' name='A1A6C5_param_value" + parIndex + "' type='text' class='form-control' >"
					        + "</div></div>";
					$("#A33541_param_values").append(input_prarm_value);
					flagIndex += temParamAry[n]+",";
				} 
			}
		}
	});
}

function A33541_Clear_Inpurt(){
	$("#A33541_sub_usercode").val("");
	$("#A33541_sub_code").val("");
	$("#A33541_param_value1").val("");
	$("#A33541_t_proc_name_url").val("");
	$("#A33541_debug_result").val("");
	$("#A33541_view_source").val("");
}

function A33541_get_format_SUB_ID(value) {
    var objResult = value;
    for(i = 0; i < A013B7_ary_SUB_ID.length; i++) {
        var obj = A013B7_ary_SUB_ID[i];
        if (obj[GetLowUpp("main_id")].toString() == value.toString()) {
            objResult = s_decode(obj[GetLowUpp("cn_name")]);
            break;
        }
    }
    return objResult.substring(objResult.length-32,objResult.length);
}

$("#A33541_btnDebug").click(function () {
    ly_index = layer.load();
    var show_url = getIP_Url() + "?sub_code=" + $("#A33541_sub_code").val() 
    	+ "&sub_usercode=" + $("#A33541_sub_usercode").val()
    	+"&session_id="+session_id+"&login_id="+login_id;
    var rooturl = show_url + "&param_name=" + $("#A33541_param_name").val();
    var source_code = "<script type=\"text/javascript\">\r\n"
         + "	$.ajax({\r\n"
         + "		type: \"POST\",\r\n"
         + "		async: false,\r\n"
         + "		url: \"" + show_url + "\",\r\n"
         + "		data:{param_name:\"" + $("#A33541_param_name").val() + "\"\r\n";
    	 + "			,session_id:\""+session_id+"\"\r\n";
    rooturl += "&param_value1"  + "=" + $("#A33541_param_value1").val();
    source_code += "			,param_value1" + ":\"" + $("#A33541_param_value1").val();
    var inputs = $("#A33541_param_values").find('input');
    for (var i = 2; i <= inputs.length+1; i++) {
        rooturl += "&param_value" + i.toString() + "=" + $(inputs[i-2]).val();
        source_code += "			,param_value" + i.toString() + ":\"" + $(inputs[i-2]).val() + "\"\r\n"
    }
    source_code += "},\r\n"
     + "		//跨域请求的URL\r\n"
     + "		dataType: \"jsonp\",\r\n"
     + "		jsonp: \"jsoncallback\",\r\n"
     + "		jsonpCallback: \"data_result\",\r\n"
     + "		success: function(data) {\r\n"
     + "		},\r\n"
     + "		error: function() {\r\n"
     + "		if(confirm(\"网络故障，请刷新网络\"))\r\n"
     + "			window.location.reload();\r\n"
     + "		},\r\n"
     + "		// 请求完成后的回调函数 (请求成功或失败之后均调用)\r\n"
     + "		complete: function(XMLHttpRequest, textStatus) {\r\n"
     + "		}\r\n"
     + "	});\r\n"
     + "\r\n"
     + "	function data_result(input_data)\r\n"
     + "	{\r\n"
     + "		//alert(input_data);\r\n"
     + "		alert(JSON.stringify(input_data));\r\n"
     + "	}\r\n"
     + "</script>";
    $("#A33541_t_proc_name_url").val(rooturl);
    $("#A33541_view_source").val(source_code);
    inputData = {};
    $.ajax({
        type: "POST",
        async: false,
        url: rooturl,
        data: inputData,
        //跨域请求的URL
        dataType: "jsonp",
        jsonp: "jsoncallback",
        //jsonpCallback: inputjsonpCallBack,
        success: function (data) {
        	A33541_get_btnDebug(data);
        },
        error: function () {
            layer.close(ly_index);
            swal({
                title: "告警",
                text: "网络异常或系统故障，请刷新页面！",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "刷新",
                closeOnConfirm: false
            },
                function () {
                layer.close(ly_index);
                window.location.reload();
            });
        },
        // 请求完成后的回调函数 (请求成功或失败之后均调用)
        complete: function (XMLHttpRequest, textStatus) {
            $("#doing").empty();
            $("#doing").attr("style", "display:none");
        }
    });
});

//调试结果
function A33541_get_btnDebug(input) {
	layer.close(ly_index);
	//查询失败
	if (Call_QryResult(input[$("#A33541_param_name").val()]) == false)
		return false;
	$("#A33541_debug_result").val(JSON.stringify(input));
}